package com.servlet;

import com.dao.PMationDao;
import com.dao.impl.PMationImpl;
import com.entry.Zgoods;
import com.util.PageModel;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet(urlPatterns = "/stock/stockpo.do")
public class StockServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=utf-8");
        HttpSession session = req.getSession();
        PMationDao pMationDao = new PMationImpl();
        int pageSize = req.getParameter("pageSize") == null ? 5 : Integer.parseInt(req.getParameter("pageSize").toString());
        int pageNo = req.getParameter("pageNo") == null ? 1 : Integer.parseInt(req.getParameter("pageNo").toString());
        PageModel<Zgoods> pm = pMationDao.findsc(pageSize,pageNo,100);
        pm.setPageNav(req.getRequestURI());
        session.setAttribute("sto", pm);
        resp.sendRedirect("./stockpo.jsp");
    }
}
